package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {

	//for i := 0; i < 100; i++ {
	//	go func(i int) {
	//		fmt.Println(i)
	//	}(i)
	//}

	wg.Add(10)
	for i := 0; i < 10; i++ {
		go func(i int) {
			fmt.Println(i)
			defer wg.Done()
		}(i)
	}

	wg.Wait()

	time.Sleep(time.Second * 2)

}
